package com.fenxiangle.yueding.feature.order.view.adapter;

import android.text.Html;
import android.view.View;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.fenxiangle.yueding.R;
import com.fenxiangle.yueding.common.util.DateTool;
import com.fenxiangle.yueding.entity.OrderType;
import com.fenxiangle.yueding.entity.bo.PublishDemandBo;
import com.suozhang.framework.framework.AM;

public class ReceiveAdapter extends BaseQuickAdapter<PublishDemandBo, BaseViewHolder> {
    public ReceiveAdapter() {
        super(R.layout.item_receive_order);
    }
    //指示器设置渐变色
    private int type;
    public void setType(int type){
        this.type=type;
    }

    @Override
    protected void convert(BaseViewHolder helper, PublishDemandBo item) {
        AM.image().bindToCircleObject(item.getUserHead(),  helper.getView(R.id.iv_my_publish_head));
        helper.setText(R.id.tv_my_publish_title, Html.fromHtml("<b><tt>邀约内容：</tt></b>"+"人数" +item.getNumPeople() + "人。 " + item.getOrderDescribe()))
                .setText(R.id.tv_my_publish_date, "时间：" + DateTool.formatTime2(item.getStartTime()) + "——" + DateTool.formatTime2(item.getEndTime()))
                .setText(R.id.tv_my_publish_address, "地点：" + item.getAgreedPlace())
                .setText(R.id.tv_my_publish_username, item.getUserName())
                .setText(R.id.tv_my_publish_credit, "信用金：￥100")
                .setText(R.id.tv_my_publish_money, "服务费：￥" + item.getUnitPrice())
                .setVisible(R.id.btn_my_publish_cancle,(type == 2))
                .setVisible(R.id.tv_my_publish_time,type == 1)
                .setText(R.id.tv_my_publish_time,DateTool.formatTime2(item.getCreateTime()))
                .setText(R.id.btn_my_publish_confrim,(type == 1?(item.getGrabStatus()==0?"抢单":"已抢"):"接单"))//btn_my_publish_cancle
                .setBackgroundRes(R.id.btn_my_publish_confrim,(item.getGrabStatus()!=0?R.drawable.bg_order_refuse:R.drawable.ic_order_btn_bg))
                .addOnClickListener(R.id.btn_my_publish_cancle)
                .addOnClickListener(R.id.btn_my_publish_confrim)
                .addOnClickListener(R.id.iv_my_publish_head)
                .addOnClickListener(R.id.tv_my_publish_username)
        ;

    }
}
